<template>
  <div class="hello">
    <el-form ref="form" :model="from" label-width="80px" class="login-form">
      <h2 class="login-title">管理系统</h2>
      <el-form-item label="用户名">
        <el-input v-model="form.loginName"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即登录</el-button>

      </el-form-item>
    </el-form>

  </div>
</template>

<script>
  import axios from 'axios'

  export default {
    name: 'HelloWorld',
    data() {
      return {
        form: {}
      }
    },
    methods: {
      onSubmit: function () {
        axios.post("http://localhost:9999/credit-user/login2", this.form).then(res => {
          //登录成功
          alert("1111")
          if (res.data.code == 100000) {
            var token = res.data.message;
            //将token设置到cookie中
            this.$cookie.set("token", token)

            this.$router.push("/borrower")
          } else {
            alert(res.data.message)
          }
        })
      },
      toregsitry: function () {
        this.$router.push("/borrower")
      }
    },
    mounted() {
      //this.$router.push("/index")
    }
  }
</script>

<style scoped>
  .login-form {
    width: 350px;
    margin: 160px auto; /* 上下间距160px，左右自动居中*/
    background-color: rgb(255, 255, 255); /* 透明背景色 */
    padding: 30px;
    border-radius: 20px; /* 圆角 */
  }

  /* 背景 */
  .hello {

    position: absolute;
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background: url("../assets/css.jpg") no-repeat;
  }

  /* 标题 */
  .login-title {
    color: #303133;
    text-align: center;
  }
</style>
